<template>
	<view>
		 <uni-list>
		 	<uni-list-item v-for="(item,index) in list" :key="index" :title="item.account" :note="item.nickname" :thumb="item.avatar_url" thumb-size="lg" rightText="点击登录" clickable @click="token_tap(item.token)"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[]
			}
		},
		onLoad() {
			this.user_phone_api()
		},
		methods: {
			token_tap(access_token) {
				uni.showModal({
					title: '提示',
					content: '是否确认切换登录账户',
					success: function (res) {
						if (res.confirm) {
							uni.setStorageSync('access_token',access_token);
							uni.reLaunch({
								url:'/pages/my/my'
							})
							// wx.closeWindow()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//首页
			user_phone_api() {
				var that = this
				that.$request(that.$Api.user_phone_api, {
					access_token: uni.getStorageSync('access_token'),
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.list = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
		}
	}
</script>

<style>
	.chat-custom-right {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
	}
	.chat-custom-text {
		font-size: 12px;
		color: #999;
	}
</style>
